import request from '../utils/request'

/** 用户接口 */
// 分页查询
export function userPageList (params) {
    return request({
        url: '/api/v1/user/pageList',
        method: 'get',
        params
    })
}

// 启用禁用
export function userSwitchStatus (params) {
    return request({
        url: '/api/v1/user/switch/status',
        method: 'post',
        params
    })
}

// 保存
export function userSave (form) {
    return request({
        url: '/api/v1/user/save',
        method: 'post',
        data: {
            userName: form.userName,
            nickName: form.nickName,
            password: form.password,
            phone: form.phone,
            email: form.email,
            enabled: form.enabled,
            isActive: form.isActive
        }
    })
}

// 修改
export function userUpdate (form) {
    return request({
        url: '/api/v1/user/update',
        method: 'post',
        data: {
            id: form.id,
            userName: form.userName,
            nickName: form.nickName,
            password: form.password,
            phone: form.phone,
            email: form.email,
            enabled: form.enabled,
            isActive: form.isActive
        }
    })
}

// 删除
export function userDeletes (parms) {
    return request({
        url: '/api/v1/user/deletes',
        method: 'post',
        data: parms
    })
}

export function getUserPieData (params, url) {
    return request({
        url,
        method: 'get',
        params
    })
}

export function getUserBarData (params, url) {
    return request({
        url,
        method: 'get',
        params
    })
}

/** 黑名单接口 */
// 分页
export function blackPageList (params) {
    return request({
        url: '/api/v1/user/black/pageList',
        method: 'get',
        params
    })
}

// 保存
export function blackSave (form) {
    return request({
        url: '/api/v1/user/black/save',
        method: 'post',
        data: {
            ip: form.ip,
            remark: form.remark
        }
    })
}

// 修改
export function blackUpdate (form) {
    return request({
        url: '/api/v1/user/black/update',
        method: 'post',
        data: {
            id: form.id,
            ip: form.ip,
            remark: form.remark
        }
    })
}

// 删除
export function blackDeletes (form) {
    return request({
        url: '/api/v1/user/black/deletes',
        method: 'post',
        data: form
    })
}
